import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int T = in.nextInt();
        int x = 998244353;
        while (T-- > 0) {
            int n = in.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = in.nextInt();
            }
            int maxLen = 0;
            for (int i = 0; i < n; i++) {
                int prev = a[i];
                int len = 1;
                for (int j = i; j < n; j++) {
                    if (a[j] > prev) {
                        prev = a[j];
                        len++;
                    }
                }
                maxLen = Math.max(maxLen, len);
            }
            Set<List<Integer>> set = new HashSet<>();
            for (int i = 0; i < n; i++) {
                int prev = a[i];
                int len = 1;
                List<Integer> list = new ArrayList<>();
                list.add(prev);
                for (int j = i; j < n; j++) {
                    if (a[j] > prev) {
                        int t = prev;
                        prev = a[j];
                        len++;
                        list.add(a[j]);
                        if (list.size() == maxLen) {
                            set.add(list);
                            list = new ArrayList<>(list);
                            list.remove(maxLen - 1);
                            prev = t;
                            len--;
                        }
                    }
                }
                if (list.size() == maxLen) {
                    set.add(list);
                }
            }
            System.out.println(set.size() % x);
        }
    }
}